package unverified

import (
	"context"

	commonTools "algo-sdk-go/common/tools"
	"algo-sdk-go/project/matchmaking/matchMaking-api/internal/logic/user_profile"
	"algo-sdk-go/project/matchmaking/matchMaking-api/internal/svc"
	"algo-sdk-go/project/matchmaking/matchMaking-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type QueryUnverifiedUserprofileLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewQueryUnverifiedUserprofileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryUnverifiedUserprofileLogic {
	return &QueryUnverifiedUserprofileLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *QueryUnverifiedUserprofileLogic) QueryUnverifiedUserprofile(req *types.QueryUserprofileRequest) (resp *types.QueryUserprofileResponse, err error) {
	userProfile, totalNum, err := l.svcCtx.UnverifiedUserProfileService.GetUnverifiedUserProfile(l.ctx, user_profile.BuildOpsCondition(req))
	if err != nil {
		return nil, err
	}

	resp = &types.QueryUserprofileResponse{
		Data: types.QueryUserprofileData{
			UserprofileList: commonTools.Cast(userProfile, user_profile.CastUserProfile),
			TotalNum:        totalNum,
		},
	}
	return
}
